<!doctype html>
<html>
<head>
<#include "/part_meta.ftl">
<title>消费记录-迈小众</title>
<link href="${st.resDomain}/css/style.css" rel="stylesheet" type="text/css">
<link href="${st.resDomain}/css/store.css" rel="stylesheet" type="text/css">
<link href="${st.resDomain}/css/autostyle.css" rel="stylesheet" type="text/css">
<link href="${st.resDomain}/css/MyCenter.css" rel="stylesheet" type="text/css">
<style>
.safe .nav ul li.none {
    background-image: none;
}
.safe .nav ul li h2 span.none {
    color: #B7BDB9;
}
</style>
</head>

<body>
<!--头部-->
<header>
  <div class="boxw store">
    <div class="header">
      <span class="f_left"><a href="javascript:history.back();" class="back"></a></span>
      <span class="title">消费记录</span>
      <span class="f_right"><a class="more"></a></span>
    </div>
    <div class="more">
      <a href="${st.userDomain}/shoppingCart" class="icon-car">购物车</a>
      <a href="${st.userDomain}/" class="icon-user">个人中心</a>
      <a href="${st.domain}/" class="icon-home">主页</a>
    </div>
  </div>
</header>
<!--头部 END-->

<div class="main boxw">
  <div class="safe">
  <div class="nav">
    <ul id="list" style="display:none;">
      <li class="-{class}-"><a href="-{detailPath}-"><h2><span class="l">-{spendTime}-</span><span class="r -{class}-">-{spend}-</span></h2></a></li>
    </ul>
  </div>
  <div id="loadTip" class="listTip">点击加载更多</div>
  </div>
</div>
<script src="${st.resDomain}/scripts/jquery-1.9.1.min.js"></script>
<script src="${st.resDomain}/scripts/com.js"></script>
<script>
	var loadListPath = g_userDomain + "/memberSpend/list/json";
	var isLoadging = false;
	var pageInfo = {};
	var $list = $("#list");
	var $loadTip = $("#loadTip");
	var spendItemTmp = $list.html();
	$list.empty().show();
	loadList();
	function loadList() {
		isLoadging = true;
		$loadTip.show().html("正在加载...");
		$.getJSON(loadListPath, pageInfo, function(data){
			isLoadging = false;
			$loadTip.html("点击加载更多");
			if (data.status !== 0) {
				showMsg("加载失败!", 'error');
				return;
			}
			var list = data.result;
			if (!list) {
				$loadTip.html("没有相关记录");
				return;
			}
			var ms,// memberSpend
			itemTmp,
			date = new Date();
			for (var i = 0; i < list.length; i++) {
				ms = list[i];
				date.setTime(ms.spendTime);
				itemTmp = spendItemTmp
				.replace(/\-\{class\}\-/g, ms.isChecked ? "" : "none")
				.replace(/\-\{detailPath\}\-/g, ms.isChecked ? (g_userDomain + "/order/detail?serialCode=" + ms.serialCode) : "javascript:;")
				.replace(/\-\{spendTime\}\-/g, date.format("yyyy-MM-dd hh:mm"))
				.replace(/\-\{spend\}\-/g, ms.isChecked ? ms.spend + "￥" : "未关联");
				$list.append(itemTmp);
			}
			pageInfo = data.pageInfo;
			if (pageInfo.nowPage == pageInfo.totalPage) {
				$loadTip.hide();
			}
			
		});
	}
	
	// 加载更多
	$loadTip.click(function() {
		if (!isLoadging && pageInfo.nowPage < pageInfo.totalPage) {
			pageInfo.nowPage = pageInfo.nowPage + 1
			pageInfo.orderType = pageInfo.orderType  === 1? "DESC" : "ASC";
			isLoadging?void(0):loadList();
		}
	});
	
	
</script>
</body>
</html>
